<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>
    <div><a href="#home">首页</a></div>
    <div><a href="#profile">个人中心</a></div>

    <div class="info"></div>
  </div>

  <script>
    window.onhashchange = function() {
      // console.log('hash 改变了')
      let html = ''
      switch(location.hash) {
        case '#home':
          html = '<h1>这是首页</h1>'
          break
        case '#profile':
          html = '<h1>个人中心页面</h1>'
          break
      }
      document.querySelector('.info').innerHTML = html
    }
  </script>
</body>
</html>